```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nginx负载均衡技术详解</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #2d3748;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .strategy-icon {
            width: 48px;
            height: 48px;
            background-color: rgba(99, 102, 241, 0.1);
        }
        .first-letter::first-letter {
            font-size: 3.5rem;
            font-weight: bold;
            float: left;
            line-height: 1;
            margin-right: 0.5rem;
            color: #4f46e5;
            font-family: 'Noto Serif SC', serif;
        }
        .timeline-item::before {
            content: '';
            position: absolute;
            left: -20px;
            top: 0;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: #4f46e5;
            border: 2px solid white;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-6">
                        Nginx负载均衡
                        <span class="text-indigo-200 block">高性能Web服务器的核心能力</span>
                    </h1>
                    <p class="text-xl text-indigo-100 mb-8">
                        探索Nginx作为现代负载均衡器的关键技术原理、策略选择和实践应用
                    </p>
                    <div class="flex space-x-4">
                        <a href="#strategies" class="bg-white text-indigo-600 hover:bg-indigo-50 px-6 py-3 rounded-lg font-medium transition duration-300">
                            <i class="fas fa-project-diagram mr-2"></i> 负载均衡策略
                        </a>
                        <a href="#visualization" class="border border-white text-white hover:bg-white hover:text-indigo-600 px-6 py-3 rounded-lg font-medium transition duration-300">
                            <i class="fas fa-chart-line mr-2"></i> 原理图解
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative w-full max-w-md">
                        <div class="absolute -top-6 -left-6 w-32 h-32 bg-indigo-300 rounded-lg opacity-20 animate-pulse"></div>
                        <div class="absolute -bottom-6 -right-6 w-32 h-32 bg-purple-300 rounded-lg opacity-20 animate-pulse delay-200"></div>
                        <div class="relative bg-white rounded-xl shadow-2xl overflow-hidden">
                            <div class="bg-gray-100 px-4 py-3 flex items-center border-b border-gray-200">
                                <div class="flex space-x-2">
                                    <span class="w-3 h-3 rounded-full bg-red-400"></span>
                                    <span class="w-3 h-3 rounded-full bg-yellow-400"></span>
                                    <span class="w-3 h-3 rounded-full bg-green-400"></span>
                                </div>
                                <div class="ml-4 text-sm text-gray-600">nginx.conf</div>
                            </div>
                            <div class="p-6 font-mono text-sm text-gray-800">
                                <div class="text-indigo-600">http {</div>
                                <div class="ml-4 text-indigo-600">upstream backend {</div>
                                <div class="ml-8">server 10.0.0.1:8080 weight=3;</div>
                                <div class="ml-8">server 10.0.0.2:8080;</div>
                                <div class="ml-8">server 10.0.0.3:8080;</div>
                                <div class="ml-4 text-indigo-600">}</div>
                                <div class="ml-4 text-indigo-600">server {</div>
                                <div class="ml-8">location / {</div>
                                <div class="ml-12">proxy_pass http://backend;</div>
                                <div class="ml-8">}</div>
                                <div class="ml-4 text-indigo-600">}</div>
                                <div class="text-indigo-600">}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Intro Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto">
            <div class="first-letter mb-12">
                <p>Nginx是一款高性能的Web服务器，广泛用于负载均衡、反向代理和HTTP缓存等场景。作为一种轻量级的负载均衡器，Nginx在分发客户端请求到后端服务器的过程中扮演着重要的角色。它具有极高的吞吐量、低延迟和较少的资源消耗，成为了现代互联网架构中常见的选择。</p>
            </div>
            
            <!-- Concept Card -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover transition duration-300">
                <div class="p-8">
                    <div class="uppercase tracking-wide text-sm text-indigo-600 font-semibold mb-1">基础概念</div>
                    <h2 class="text-2xl font-bold mb-4">负载均衡的基本概念</h2>
                    <p class="text-gray-600 mb-6">负载均衡指的是将客户端请求分发到多个服务器（通常是后端应用服务器或数据库服务器）上，从而实现以下目标：</p>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-indigo-600 mt-0.5">
                                <i class="fas fa-shield-alt"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-gray-700"><span class="font-medium">提升应用的可用性和容错性</span>：如果某台服务器故障，负载均衡器能够将请求转发到其他健康的服务器。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-indigo-600 mt-0.5">
                                <i class="fas fa-tachometer-alt"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-gray-700"><span class="font-medium">提升并发处理能力</span>：通过分发请求，避免单一服务器的过载，充分利用多台服务器的计算资源，提升系统的处理能力。</p>
                            </div>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-6 w-6 text-indigo-600 mt-0.5">
                                <i class="fas fa-bolt"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-gray-700"><span class="font-medium">减少响应延迟</span>：通过就近的服务器响应请求，提高访问速度。</p>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Visualization Section -->
    <section id="visualization" class="py-16 px-4 sm:px-6 lg:px-8 bg-gray-100">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-12">Nginx负载均衡工作原理</h2>
            
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="p-8">
                    <div class="flex justify-center mb-8">
                        <div class="max-w-3xl w-full">
                            <div class="mermaid">
                                graph LR
                                    A[客户端] -->|请求| B[Nginx<br>负载均衡器]
                                    B --> C[后端服务器1]
                                    B --> D[后端服务器2]
                                    B --> E[后端服务器3]
                                    C -->|响应| B
                                    D -->|响应| B
                                    E -->|响应| B
                                    B -->|响应| A
                            </div>
                        </div>
                    </div>
                    <div class="relative">
                        <div class="absolute top-0 left-0 w-full h-full flex items-center justify-center">
                            <div class="bg-indigo-100 rounded-full w-64 h-64 opacity-20"></div>
                        </div>
                        <div class="relative">
                            <h3 class="text-xl font-semibold mb-4">Nginx负载均衡的基本工作流程：</h3>
                            <ol class="list-decimal list-inside space-y-4 text-gray-700">
                                <li>客户端发起请求</li>
                                <li>Nginx根据负载均衡策略选择一个后端服务器（或多个后端服务器）</li>
                                <li>请求被转发到选择的后端服务器</li>
                                <li>后端服务器处理请求并返回响应，Nginx将响应返回给客户端</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Strategies Section -->
    <section id="strategies" class="py-16 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-4">Nginx负载均衡策略</h2>
            <p class="text-center text-gray-600 max-w-3xl mx-auto mb-12">Nginx支持多种负载均衡策略，可以根据具体需求选择最合适的策略</p>
            
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
                <!-- Round-robin -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="strategy-icon rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-sync-alt text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">轮询 (Round-robin)</h3>
                        </div>
                        <p class="text-gray-600 mb-4">这是Nginx的默认负载均衡策略。在该策略下，Nginx会按照顺序依次将请求转发给每个后端服务器。</p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <h4 class="font-semibold text-indigo-800 mb-2">特点：</h4>
                            <div class="flex items-start mb-1">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">简单、易于实现，适合服务器性能相近的场景</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">没有考虑服务器负载，可能导致某些服务器过载</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Least Connections -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="strategy-icon rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-project-diagram text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">最少连接 (Least Connections)</h3>
                        </div>
                        <p class="text-gray-600 mb-4">该策略将请求转发给当前连接数最少的后端服务器。Nginx会定期检查每台服务器的连接数。</p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <h4 class="font-semibold text-indigo-800 mb-2">特点：</h4>
                            <div class="flex items-start mb-1">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">适用于后端服务器处理请求的时间差异较大的场景</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">可能会对某些请求量很小但频繁的服务器造成不公平的负载</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- IP Hash -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="strategy-icon rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-fingerprint text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">IP哈希 (IP Hash)</h3>
                        </div>
                        <p class="text-gray-600 mb-4">Nginx通过客户端的IP地址来计算哈希值，根据哈希值决定请求应该转发到哪一台后端服务器。</p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <h4 class="font-semibold text-indigo-800 mb-2">特点：</h4>
                            <div class="flex items-start mb-1">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">适用于需要会话粘滞性的场景</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">无法均匀分配负载，可能导致某些服务器过载</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Weighted Round-robin -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="strategy-icon rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-balance-scale-right text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">加权轮询 (Weighted Round-robin)</h3>
                        </div>
                        <p class="text-gray-600 mb-4">加权轮询是轮询的一种扩展，允许配置每个后端服务器的权重，权重高的服务器会处理更多的请求。</p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <h4 class="font-semibold text-indigo-800 mb-2">特点：</h4>
                            <div class="flex items-start mb-1">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">适用于后端服务器性能差异较大的场景</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">需要精细化的权重配置，较为复杂</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Weighted Least Connections -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="strategy-icon rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-code-branch text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">加权最少连接 (Weighted Least Connections)</h3>
                        </div>
                        <p class="text-gray-600 mb-4">这种策略是最少连接的扩展，允许为每个后端服务器配置权重。在选择请求转发的目标服务器时，不仅考虑服务器的连接数，还会参考服务器的权重。</p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <h4 class="font-semibold text-indigo-800 mb-2">特点：</h4>
                            <div class="flex items-start mb-1">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">能够动态调整服务器负载，适用于负载波动较大的场景</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                <span class="text-gray-700">需要根据实际负载动态调整权重</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- High Availability Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-gray-100">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-12">Nginx负载均衡的容错与高可用性</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                    <div class="p-8">
                        <h3 class="text-2xl font-bold mb-6">健康检查与故障恢复机制</h3>
                        
                        <div class="space-y-6">
                            <div class="flex">
                                <div class="flex-shrink-0">
                                    <div class="flex items-center justify-center h-12 w-12 rounded-md bg-green-100 text-green-600">
                                        <i class="fas fa-heartbeat text-xl"></i>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h4 class="text-lg font-medium text-gray-900">健康检查</h4>
                                    <p class="mt-1 text-gray-600">
                                        Nginx通过定期向后端服务器发送健康检查请求，确保所有的后端服务器处于健康状态。如果某台服务器失败（如响应失败或超时），Nginx会自动将该服务器从负载均衡池中移除，直到该服务器恢复健康。
                                    </p>
                                </div>
                            </div>
                            
                            <div class="flex">
                                <div class="flex-shrink-0">
                                    <div class="flex items-center justify-center h-12 w-12 rounded-md bg-red-100 text-red-600">
                                        <i class="fas fa-server text-xl"></i>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h4 class="text-lg font-medium text-gray-900">服务器失效自动移除</h4>
                                    <p class="mt-1 text-gray-600">
                                        当Nginx检测到某台后端服务器不可用时，会自动将其移除负载均衡池，避免将请求转发到不可用的服务器。一旦服务器恢复健康，Nginx会将其重新加入池中，继续接受请求。
                                    </p>
                                </div>
                            </div>
                            
                            <div class="flex">
                                <div class="flex-shrink-0">
                                    <div class="flex items-center justify-center h-12 w-12 rounded-md bg-blue-100 text-blue-600">
                                        <i class="fas fa-redo-alt text-xl"></i>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h4 class="text-lg font-medium text-gray-900">请求重试</h4>
                                    <p class="mt-1 text-gray-600">
                                        Nginx支持请求重试功能。如果请求转发失败（如连接失败或超时），它会自动尝试将请求发送到其他健康的后端服务器，以实现容错。
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                    <div class="p-8">
                        <h3 class="text-2xl font-bold mb-6">性能优化技术</h3>
                        
                        <div class="space-y-6">
                            <div class="flex">
                                <div class="flex-shrink-0">
                                    <div class="flex items-center justify-center h-12 w-12 rounded-md bg-purple-100 text-purple-600">
                                        <i class="fas fa-list-ol text-xl"></i>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h4 class="text-lg font-medium text-gray-900">请求队列管理</h4>
                                    <p class="mt-1 text-gray-600">
                                        Nginx通过高效的请求队列管理机制，能够避免因高并发请求导致性能瓶颈。通过合理配置`worker_connections`，可以确保Nginx在高并发下能够处理更多的连接。
                                    </p>
                                </div>
                            </div>
                            
                            <div class="flex">
                                <div class="flex-shrink-0">
                                    <div class="flex items-center justify-center h-12 w-12 rounded-md bg-yellow-100 text-yellow-600">
                                        <i class="fas fa-memory text-xl"></i>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h4 class="text-lg font-medium text-gray-900">缓冲区优化</h4>
                                    <p class="mt-1 text-gray-600">
                                        通过优化缓冲区大小、调整`proxy_buffer_size`、`proxy_buffers`等参数，可以减少后端服务器和Nginx之间的数据传输延迟，提升性能。
                                    </p>
                                </div>
                            </div>
                            
                            <div class="flex">
                                <div class="flex-shrink-0">
                                    <div class="flex items-center justify-center h-12 w-12 rounded-md bg-indigo-100 text-indigo-600">
                                        <i class="fas fa-lock text-xl"></i>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h4 class="text-lg font-medium text-gray-900">SSL终端加速</h4>
                                    <p class="mt-1 text-gray-600">
                                        对于使用HTTPS协议的请求，Nginx可以作为SSL终端，进行SSL/TLS解密，将明文请求转发到后端服务器。通过配置`ssl_ciphers`、`ssl_protocols`等参数，可以提升加密过程的效率，减少服务器负担。
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Use Cases Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-12">Nginx负载均衡的使用场景</h2>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center justify-center h-16 w-16 rounded-md bg-indigo-100 text-indigo-600 mb-4 mx-auto">
                            <i class="fas fa-globe text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold text-center mb-3">Web服务负载均衡</h3>
                        <p class="text-gray-600 text-center">
                            Nginx可以将HTTP请求分发到多个Web服务器，提高Web应用的并发处理能力和稳定性。
                        </p>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center justify-center h-16 w-16 rounded-md bg-green-100 text-green-600 mb-4 mx-auto">
                            <i class="fas fa-network-wired text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold text-center mb-3">API网关</h3>
                        <p class="text-gray-600 text-center">
                            在微服务架构中，Nginx作为API网关，处理客户端请求并将请求转发到相应的微服务实例。
                        </p>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover transition duration-300">
                    <div class="p-6">
                        <div class="flex items-center justify-center h-16 w-16 rounded-md bg-blue-100 text-blue-600 mb-4 mx-auto">
                            <i class="fas fa-database text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold text-center mb-3">数据库负载均衡</h3>
                        <p class="text-gray-600 text-center">
                            在数据库集群中，Nginx可以作为负载均衡器，将查询请求分发到多个数据库节点，提升数据库处理能力。
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-white transition duration-300">
                        <i class="fas fa-link mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
                <div class="flex space-x-6">
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```